package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {
    /**
     * 新增一个菜单分类
     *
     * @param category
     */

    @AutoFill(value = OperationType.INSERT)
    void add(Category category);

    /**
     * 分页查询菜单分类
     *
     * @param
     * @return
     */
    Page<Category> selectByPage(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 删除菜品分类
     *
     * @param id
     */
    @Delete("delete  from category where id=#{id}")
    void deleteById(Long id);

    /**
     * 更新分类
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Category category);

    /**
     * 按分类展示分类
     *
     * @param type
     * @return
     */
    List<Category> listByType(Integer type);

    @Select("select * from category where id=#{id}")
    Category selectById(Long id);

    @Select("select * from category ")
   List<Category>  selectAll();
}
